<template>
	<view>
		<totalMask :show.sync="isShow" :showType="showType">
			<view class="nvue-flex">
				<view class="title-bg">
					<text class="title">钱包</text>
				</view>
				
				<view class="wallet-bg">
					<view class="balance-title-bg">
						<image class="balance-img" src="@/static/live/wallet_balance.png"></image>
						
						<text class="balance-title">本次直播收益</text>
					</view>
					
					<view class="balance-bg">
						<text class="symbol">¥</text>
						<text class="balance">{{current_income}}</text>
					</view>
					
					<view class="total-income-bg">
						<text class="income">累计收入:{{total_income}}元</text>
					</view>
				</view>
			</view>
		</totalMask>
	</view>
</template>

<script>
	import {
		roomIncomeInfo
	} from "@/api/newLive.js";
	import storage from "@/utils/storage";
	
	export default {
		data() {
			return {
				isShow: false,
				showType: 0,
				
				current_income: 0,
				total_income: 0,
			}
		},
		destroyed() {
			uni.$off("onShowWallet")
		},
		mounted() {
			uni.$on("onShowWallet", () => {
				this.isShow = true
				this.showType = 11
				
				this.getData()
			})
		},
		methods: {
			/**
			 * 网络请求
			 */
			async getData() {
				let res = await roomIncomeInfo(storage.getLiveRoomInfo().id)
				this.current_income = res.data.this_field
				this.total_income = res.data.accumulate
			}
		},
	}
</script>

<style lang="scss" scoped>
	.title-bg {
		width: 300rpx;
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: center;
	}
	.title {
		color: #191919;
		font-size: 32rpx;
	}
	
	.wallet-bg {
		margin-top: 50rpx;
		width: 702rpx;
		background: linear-gradient(90deg, #A4D79F, #4FB784);
		border-radius: 20rpx;
		padding: 0rpx 30rpx;
		box-sizing: border-box;
		overflow: hidden;
		display: flex;
		flex-direction: column;
		align-items: center;
	}
	
	.balance-title-bg {
		margin-top: 27rpx;
		width: 642rpx;
		display: flex;
		flex-direction: row;
		align-items: center;
	}
	
	.balance-img {
		width: 55rpx;
		height: 55rpx;
	}
	
	.balance-title {
		margin-left: 19rpx;
		color: white;
		font-size: 30rpx;
	}
	
	.balance-bg {
		margin-top: 40rpx;
		overflow: hidden;
		display: flex;
		flex-direction: row;
		align-items: center;
	}
	
	.symbol {
		color: white;
		font-size: 30rpx;
		font-weight: bold;
		margin-right: 16rpx;
	}
	
	.balance {
		color: white;
		font-size: 60rpx;
		font-weight: bold;
	}
	
	.total-income-bg {
		margin-top: 70rpx;
		width: 642rpx;
		height: 80rpx;
		border-top: 2rpx solid rgba(255, 255, 255, 0.3);
		display: flex;
		flex-direction: row;
		align-items: center;
	}
	
	.income {
		color: white;
		font-size: 26rpx;
	}
	
</style>